package cn.fay.chapter17;

import java.util.AbstractList;
/**
 * 享元的解决方案
 * 当你寻找值时，才get()产生它，实际上list并不组装。
 * @author emellend
 *
 */
public class CountingIntegerList extends AbstractList<Integer> {
	private int size;
	public CountingIntegerList(int size) {
		this.size=size<0?0:size;
	}
	@Override
	public Integer get(int index) {
		return Integer.valueOf(index);
	}

	@Override
	public int size() {
		return size;
	}
	public static void main(String[] args) {
		System.out.println(new CountingIntegerList(30));
	}

}
